

public class MyStack {

	 int iTop;
	 Object stack[];


	public  MyStack(int iSize) {

		stack = new Object[iSize];
		iTop = -1;

	}
	public boolean isEmpty() {

		if (iTop < 0) {
			return true;
		} else {
			return false;
		}
	}
	public boolean isFull() {

		if (iTop == (stack.length - 1)) {
			return true;
		} else {
			return false;
		}
	}
	public Object top() {
		if (isEmpty()) {
			System.out.println("The stack is empty!");
			return null;
		} else {
			return stack[iTop];
		}
	}
	public void push(Object newObject) {

		if (isFull()) {
			System.out.println("The stack is full!");
			
		} else {
			stack[++iTop] = newObject;
		}
	}
	public  Object pop() {
		if (isEmpty()) {
			
			System.out.println("The stack is empty!");
			return "";
		} else {

			return stack[iTop--];
		}
	}
	public void show() {
		
		if (isEmpty()) {
			System.out.println("The stack is empty!");

		} else {
			for (int i = iTop; i > -1; i--) {
				System.out.println(stack[i]);
			}
		}
	}
}